// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import 'element-ui/lib/theme-chalk/base.css';

import axios from 'axios'
// axios.default.baseURL = "http://127.0.0.1:8000/api/"
axios.defaults.headers.post['Content-Type'] = 'application/json';
Vue.prototype.$axios = axios
Vue.prototype.$url = "http://127.0.0.1:8001/api/"

Vue.use(ElementUI);

Vue.config.productionTip = false




// 拦截器配置
router.beforeEach(function(to,from,next){
  if(to.meta.requireAuth){
    // 想去的路由只能登陆成功之后才能去,接下来判断是否登陆
    if(store.state.token){
      next()
    }else{
      //未登录将跳转到login页面，且带有参数，这个参数是登录成功之后需要跳转的页面（我本来想进入的页面）
      next({name:'login', query:{backUrl:to.fullPath}})
    }
  }else{
    next()
  }

})

import store from './store/store.js'


/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})


// router.beforeRouteUpdate(function(to, from, next){
//   console.log(123)
// })
